package com.fdb.efp.nls.service.impl.sx;

import com.fdb.efp.nls.service.domain.sx.NlsCreditExpInfo;
import com.fdb.efp.nls.service.facade.sx.NlsCreditExpInfoService;
import com.fdb.efp.nls.service.vo.sx.NlsCreditExpInfoVO;
import com.fdb.basic.framework.core.base.FrameworkService;
import com.fdb.efp.nls.service.dao.sx.NlsCreditExpInfoDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>ServiceImpl: 网贷授信申请表				<p>
 * @author ligm
 * @date 2019-03-04
 */
@Service("nlsCreditExpInfoService")
public class NlsCreditExpInfoServiceImpl implements NlsCreditExpInfoService, FrameworkService {
	
	private static Logger logger = LoggerFactory.getLogger(NlsCreditExpInfoServiceImpl.class);

	@Autowired
	private NlsCreditExpInfoDao nlsCreditExpInfoDao;

	/**
	 * 查询用户权限数据
	 * 数据量较大，改成分页查询
	 */
	@SuppressWarnings("unchecked")
	public List<NlsCreditExpInfoVO> queryAllOwner(NlsCreditExpInfoVO nlsCreditInfoVo) {

		logger.debug("查询当前用户");
		List<NlsCreditExpInfoVO> list = null;
		try {
			List<NlsCreditExpInfo> nlsCreditInfos = nlsCreditExpInfoDao.queryAllOwner(nlsCreditInfoVo);
			logger.debug("当前查询本人所属数据信息的结果集数量为:"+ nlsCreditInfos.size());
			pageSet(nlsCreditInfos, nlsCreditInfoVo);
			list = (List<NlsCreditExpInfoVO>) beansCopy(nlsCreditInfos, NlsCreditExpInfoVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}

		return list;

	}
	@Override
	public List<NlsCreditExpInfoVO> queryAllCurrOrg(NlsCreditExpInfoVO nlsCreditInfoVo) {
		logger.debug("查询当前用户及所属机构");
		List<NlsCreditExpInfoVO> list = null;
		try {
			List<NlsCreditExpInfo> nlsCreditInfos = nlsCreditExpInfoDao.queryAllCurrOrg(nlsCreditInfoVo);
			logger.debug("当前查询本人所属数据信息的结果集数量为:"+ nlsCreditInfos.size());
			nlsCreditInfoVo.setTotal(nlsCreditExpInfoDao.queryCount());
			pageSet(nlsCreditInfos, nlsCreditInfoVo);
			list = (List<NlsCreditExpInfoVO>) beansCopy(nlsCreditInfos, NlsCreditExpInfoVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}

		return list;
	}

	@Override
	public List<NlsCreditExpInfoVO> queryAllCurrDownOrg(NlsCreditExpInfoVO nlsCreditInfoVo) {
		logger.debug("查询当前用户所在机构及下属机构");
		List<NlsCreditExpInfoVO> list = null;
		try {
			List<NlsCreditExpInfo> nlsCreditInfos = nlsCreditExpInfoDao.queryAllCurrDownOrg(nlsCreditInfoVo);
			logger.debug("当前查询本人所属数据信息的结果集数量为:"+ nlsCreditInfos.size());
			nlsCreditInfoVo.setTotal(nlsCreditExpInfoDao.queryCount());
			pageSet(nlsCreditInfos, nlsCreditInfoVo);
			list = (List<NlsCreditExpInfoVO>) beansCopy(nlsCreditInfos, NlsCreditExpInfoVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}

		return list;
	}

	@Override
	public List<NlsCreditExpInfoVO> queryAllCurrOwnerPrd(NlsCreditExpInfoVO nlsCreditInfoVo) {
		logger.debug("查询产品");
		List<NlsCreditExpInfoVO> list = null;
		try {
			List<NlsCreditExpInfo> nlsCreditInfos = nlsCreditExpInfoDao.queryAllCurrOwnerPrd(nlsCreditInfoVo);
			logger.debug("当前查询本人所属数据信息的结果集数量为:"+ nlsCreditInfos.size());
			nlsCreditInfoVo.setTotal(nlsCreditExpInfoDao.queryCount());
			pageSet(nlsCreditInfos, nlsCreditInfoVo);
			list = (List<NlsCreditExpInfoVO>) beansCopy(nlsCreditInfos, NlsCreditExpInfoVO.class);
		} catch (Exception e) {
			logger.error("数据转换出现异常!", e);
		}

		return list;
	}

	@Override
	public int queryCount() {
		logger.debug("当前查授信申请失效表数据:");
		return nlsCreditExpInfoDao.queryCount();
	}

}

